
var $form;
var form;
var $;
layui.config({
	base : "../../js/"
}).use(['form','layer','upload','laydate'],function(){
	form = layui.form();
	var layer = parent.layer === undefined ? layui.layer : parent.layer;
		$ = layui.jquery;
		$form = $('form');
		laydate = layui.laydate;
		
	var oid = window.sessionStorage.getItem("organizeId");
		

    layui.upload({
    	elem: '.memLoad', //绑定元素
    	url : $.httpRootPath() + "/api/web/load/member/preEntry",
    	ext: 'xls',
  		type: 'file',
         success: function(res){
         	if(res.code != "00"){
         		showNotice("模板解析出错，具体请查看上传结果");
         		$("#uploadResutl").html(res.msg);
         	}else{
         		if(res.data.length == 0){
         			showNotice("上传结果为空");
         			return;
         		}
         		var result = ""
         		for(var i =0;i<res.data.length;i++){
         			var obj = res.data[i]
         			result += "<p>编号："+obj.memberNum+":"+obj.upState+"</p>"
         		}
         		$("#uploadResutl").html(result);
         	}
  		},
         error: function(){
         	 console.log("失败"); 
      	//请求异常回调
    	}
    });
    
	function showNotice(result){
		if(result != "open"){
			window.sessionStorage["uploadResult"] = result;
		}
		layer.open({
	        type: 1,
	        title: "上传结果",
	        closeBtn: false,
	        area: '310px',
	        shade: 0.8,
	        id: 'LAY_layuipro',
	        btn: ['确定'],
	        moveType: 1,
	        content: '<div style="padding:15px 20px; text-align:justify; line-height: 22px; text-indent:2em;border-bottom:1px solid #e2e2e2;">'+result+'</div>',
	        success: function(layero){
				var btn = layero.find('.layui-layer-btn');
				btn.css('text-align', 'center');
				btn.on("click",function(){
					window.sessionStorage.setItem("showNotice","true");
				})
	        }
	    });
	}
})
$(".pre-modle-down").click(function() {
	var str  = $.httpRootPath()+"/api/web/load/member/preEntry";
	window.location.href = str;
});